package com.spider.spiderorderadmin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spider.spiderorderadmin.entity.model.DataDictionary;
import com.spider.spiderorderadmin.entity.model.OperationRecord;
import com.spider.spiderorderadmin.entity.param.OperationLogQueryParam;
import com.spider.spiderorderadmin.mapper.OperationRecordMapper;
import com.spider.spiderorderadmin.service.OperationLogService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


/**
 * @author xiong.bo
 * @version 1.0
 * @date 2021/1/23 10:47
 */
@Service
public class OperationLogServiceImpl extends ServiceImpl<OperationRecordMapper, OperationRecord>
        implements OperationLogService {

    @Override
    public Page<OperationRecord> findOperationRecordList(OperationLogQueryParam queryParam) {
        LambdaQueryWrapper<OperationRecord> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.hasText(queryParam.getUsername()), OperationRecord::getUsername, queryParam.getUsername());
        queryWrapper.like(StringUtils.hasText(queryParam.getAccessPath()), OperationRecord::getAccessPath, queryParam.getAccessPath());
        queryWrapper.orderByDesc(OperationRecord::getCreateTime);
        return this.baseMapper.selectPage(queryParam.buildPage(), queryWrapper);
    }
}
